package com.wzdigit.wms.wms.service.core.putaway;

import com.wzdigit.wms.basic.domain.order.PutawayTaskDtl;
import com.wzdigit.wms.basic.mapper.core.order.PutawayTaskDtlMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 上架任务明细 服务类
 * </p>
 *
 * @author
 * @since 2021-01-19
 */
@Service
@Slf4j
public class PutawayTaskDtlService {

    @Autowired
    PutawayTaskDtlMapper putawayTaskDtlMapper;

    /**
     * 根据入参生成一条新的记录
     *
     * @param putawayTaskDtl
     * @return
     */
    public PutawayTaskDtl addNewOne(PutawayTaskDtl putawayTaskDtl) {
        int row = putawayTaskDtlMapper.insert(putawayTaskDtl);
        log.info("成功新增{}条记录", row);

        return putawayTaskDtl;
    }

    /**
     * 根据入参更新一条新的记录
     *
     * @param putawayTaskDtl
     * @return
     */
    public PutawayTaskDtl updateOne(PutawayTaskDtl putawayTaskDtl) {
        int row = putawayTaskDtlMapper.updateById(putawayTaskDtl);
        log.info("成功更新{}条记录", row);

        return putawayTaskDtl;
    }

    /**
     * 根据多个入参实体更新
     *
     * @param putawayTaskDtlList
     * @return
     */
    public List<PutawayTaskDtl> updateList(List<PutawayTaskDtl> putawayTaskDtlList) {

        for (PutawayTaskDtl putawayTaskDtl : putawayTaskDtlList) {
            updateOne(putawayTaskDtl);
        }

        return putawayTaskDtlList;
    }

    /**
     * 根据入参List实体添加
     *
     * @param putawayTaskDtlList
     * @return
     */
    public List<PutawayTaskDtl> addNewList(List<PutawayTaskDtl> putawayTaskDtlList) {

        for (PutawayTaskDtl putawayTaskDtl : putawayTaskDtlList) {
            addNewOne(putawayTaskDtl);
        }
        return putawayTaskDtlList;
    }
}
